package com.lagou.service.impl;

import com.lagou.dao.ResourceCategoryMapper;
import com.lagou.domain.ResourceCategory;
import com.lagou.service.ResourceCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ResourceCategoryServiceImpl implements ResourceCategoryService {


    @Autowired
    private ResourceCategoryMapper resourceCategoryMapper;


    @Override
    public List<ResourceCategory> findAllResourceCategory() {

        List<ResourceCategory> allResourceCategory = resourceCategoryMapper.findAllResourceCategory ();

        return allResourceCategory;
    }

    /*添加资源分类*/
    @Override
    public void saveResourceCategory(ResourceCategory resourceCategory) {

        //补全信息
        Date date = new Date ();
        resourceCategory.setCreatedTime (date);
        resourceCategory.setUpdatedTime (date);
        resourceCategory.setCreatedBy ("zyd");
        resourceCategory.setUpdatedBy ("zyd1");
        resourceCategoryMapper.saveResourceCategory (resourceCategory);
    }

    /*修改资源分类*/
    @Override
    public void updateResourceCategory(ResourceCategory resourceCategory) {

        //补全信息
        resourceCategory.setUpdatedTime (new Date ());
        resourceCategory.setUpdatedBy ("zyd1");

        //调用mapper方法
        resourceCategoryMapper.updateResourceCategory (resourceCategory);
    }

    /*根据id删除资源*/
    @Override
    public void deleteResourceCategoryByResourceId(Integer resourceId) {
        //调用mapper方法
        resourceCategoryMapper.deleteResourceCategoryByResourceId (resourceId);
    }

    /*删除资源分类*/
    @Override
    public void deleteResourceCategoryById(Integer id) {
        //调用mapper方法
        resourceCategoryMapper.deleteResourceCategoryById (id);
    }

}
